/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server;

import java.util.ArrayList;
import java.util.UUID;

/**
 * Class that represents a Test. It's a collection of test specifications and one unique identifier
 * @author gravena
 */
public class Test {
    private ArrayList<TestSpec> specList; /* List of test specifications */
    private UUID id; /* Unique identifier for the test */
    private String name; /* User friendly name */
    
    public Test() {
        this.specList = new ArrayList<>();
        this.id = UUID.randomUUID();        
        this.name = "default";
    }
    
    public Test(UUID id) {
        this.specList = new ArrayList<>();
        this.id = id;
        this.name = "default";
    }        
    
    /**
     * Search for a test identified by id in the suplied Test list.
     * @param list ArrayList of Test objects
     * @param id Unique identifier (UUID) of the desired Test
     * @return The Test object identified by id or null if he is not in the list
     */
    public static Test searchUUID(ArrayList<Test> list, UUID id) {
        
        for(int i=0;i<list.size();i++) {   
            if(list.get(i).getId().compareTo(id) == 0) {
                return list.get(i);
            }
        }
        
        return null;
    }
    
    public boolean addTestSpec(TestSpec t) {
        return specList.add(t);
    }

    public UUID getId() {
        return id;
    }
    
    public ArrayList<TestSpec> getSpecList() {
        return this.specList;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    
    
}
